class code3 {
    public List<List<String>> groupAnagrams(String[] strs) {
        Map<String,List<String>> map = new HashMap<>();
        for(String ss:strs) {
            //对每个ss进行重排列
            char[] s = ss.toCharArray();
            Arrays.sort(s);
            String key = new String(s);
            //加入list 加入map
            List<String> list = map.getOrDefault(key,new ArrayList<String>());
            list.add(ss);
            map.put(key,list);
        }
        return new ArrayList<List<String>>(map.values());
    }
}